package com.ctgu.server;

import com.alibaba.fastjson2.util.DateUtils;
import org.junit.jupiter.api.Test;

import java.io.*;
import java.nio.file.Files;
import java.util.Date;
import java.util.UUID;

public class testDateUtils {
    @Test
    public void testDateUtilGetDate() {
        System.out.println(DateUtils.format(new Date(), "yyyy/MM"));
        System.out.println(UUID.randomUUID());
        File file=new File("C:\\Users\\kvzjj\\Pictures\\v2-48d30bbc0844df364872046cf03761b4_720w.webp");
        System.out.println( file.getName().substring(file.getName().lastIndexOf(".") +1));;
        System.out.println(file.getName());

        try (InputStream inputStream = Files.newInputStream(file.toPath())) {

            String imgName = DateUtils.format(new Date(), "yyyy/mm/")
                    + UUID.randomUUID()
                     + file.getName().substring(file.getName().lastIndexOf(".") );
            System.out.println(imgName);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }



    }
}
